﻿using System.Runtime.InteropServices;
using System.Text;

namespace LpbPrj.Client.Tools.Helper
{
    public class IniHelper
    {
        //该函数用来写入INI文件的内容
        [DllImport("kernel32")]          //调用WindowsAPI函数
        private static extern int WritePrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, string lpFileName);

        public static int SetIniValue(string AppName, string KeyName, string Value, string FileFullPath)
        {
            //对INI文件进行写操作
            return WritePrivateProfileString(AppName, KeyName, Value, FileFullPath);
        }

        //该函数用来读取INI文件的内容
        [DllImport("kernel32")]          //调用WindowsAPI函数
        private static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
        public static string GetIniValue(string AppName, string KeyName, string FileFullPath)
        {
            //对INI文件进行读操作
            StringBuilder strb = new StringBuilder();
            int i = GetPrivateProfileString(AppName, KeyName, "0", strb, 100, FileFullPath);
            return strb.ToString();
        }



    }
}